package cc.vant.wechat.model;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.CompositeByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;

public class LoginSignupOutHandler extends ChannelOutboundHandlerAdapter {

    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
        if (msg instanceof ByteBuf) {
            ByteBuf deli = Unpooled.copiedBuffer(MyApplication.DELIMITER);
            ByteBuf byteBuf = new CompositeByteBuf(ctx.alloc(), true, 2, (ByteBuf) msg, deli);
            ctx.write(byteBuf);
        }
    }

//    @Override
//    public void flush(ChannelHandlerContext ctx) throws Exception {
//
//    }
//
//    @Override
//    public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception {
//
//    }
//
//    @Override
//    public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
//        super.disconnect(ctx, promise);
//    }
//
//    @Override
//    public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
//    }
//
//    @Override
//    public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
//    }
//
//    @Override
//    public void read(ChannelHandlerContext ctx) throws Exception {
//    }
}
